home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 31
/
Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso
/
Aminet
/
dev
/
c
/
vbccm68k.lha
/
vbcc
/
doc
/
vbccm68k.doc
< prev
next >
Wrap
Text File
|
1999-03-07
|
14KB
|
315 lines
vbcc - C compiler (c) in 1995-99 by Volker Barthelmann
INTRODUCTION
vbcc is a free portable and retargetable ANSI C compiler.
It is clearly split into a target independant and a target dependant
part and supports emulating datatypes of the target machine on any
other machine so that it is possible to e.g. make a crosscompiler for
a 64bit machine on a 32bit machine.
This document only deals with the target dependant parts of the
Amiga68k version.
LEGAL
vbcc is (c) in 1995-99 by Volker Barthelmann. All code is written by me
and may be freely redistributed as long as no modifications are made
and nothing is charged for it.
Non-commercial usage of vbcc is allowed without any restrictions.
Commercial usage needs my written consent.
Sending me money, gifts, postcards etc. would of course be very nice
and may encourage further development of vbcc, but is not legally or
morally necessary to use vbcc.
ADDITIONAL OPTIONS FOR THIS VERSION
-cpu=n Generate code for cpu n (e.g. -cpu=68020), default: 68000
-fpu=n Generate code for fpu n (e.g. -fpu=68881), default: 0
-sd Use small data model (see below).
-sc Use small code model (see below).
-prof Insert code for profiling (not really usable yet).
-g Generate debugging hunks which contain addresses of static
objects and links assembly instructions to source lines.
This does not work with -gas.
-const-in-data
By default constant data will be placed in the code
section (and therefore is accessable with faster pc-relative
addressing modes). Using this option it will be placed in the
data section.
This could e.g. be useful if you want to use small data and
small code, but your code gets too big with all the constant
data.
Note that on operating systems with memory protection this
option will disable write-protection of constant data.
-use-framepointer
By default automatic variables are addressed through a7
instead of a5. This generates slightly better code, because
the function entry and exit overhead is reduced and a5 can be
used as register variable etc.
However this may be a bit confusing when debugging and you
can force vbcc to use a5 as a fixed framepointer.
-no-addressing-modes
The intermediate code does not contain any of the 68k
addressing modes, so if they are to be used an extra pass
over the intermediate code is necessary to recognize certain
patterns that can be expressed using a 68k addressing mode.
By default vbcc tries to use some 68k addressing modes.
Currently (ax)+ and subsets of (displ,ax,dy*skal) are used.
However not all cases where those addressing modes could be
used are recognized.
With this option you can prevent vbcc from searching for
possible addressing modes. This may simplify debugging.
-no-delayed-popping
By default arguments of function calls are not always popped
from the stack immediately after the call, so that the
arguments of several calls may be popped at once.
With this option vbcc can be forced to pop them after every
function call.
This may simplify debugging and very slightly reduce the
stack size needed by the compiled program.
-gas Create output suitable for the GNU assembler. This is
mainly useful to create code for other operating systems.
-no-fp-return
Do not return floats and doubles in floating-point registers
even if code for an fpu is generated. This is mainly useful
to create code for other operating systems.
-no-mreg-return
Do not use multiple registers to return types that do not
fit into a single register. This is mainly for backwards
compatibility.
-d2scratch obsolete
-noa4 obsolete
SOME INTERNALS
The current version generates assembler output for use with the PhxAss
assembler (c) by Frank Wille. Most peephole optimizations are done by the
assembler so vbcc only does some that the assembler cannot make.
The generated executables will probably only work with OS2.0 or higher.
With -gas assembler output suitable for the GNU assembler is generated
(the version must understand the Motorola syntax - some old ones do not).
The output is only slightly modified from the PhxAss-output and will
therefore result in worse code on gas. However this code generator should
be usable on most operating systems on 68k machines that way.
The register names are:
a0, a1, a2, a3, a4, a5, a6, a7
d0, d1, d2, d3, d4, d5, d6, d7
fp0, fp1, fp2, fp3, fp4, fp5, fp6, fp7
The registers d0, d1, a0, a1, fp0 and fp1 are used as scratch registers
(i.e. they can be destroyed in function calls), all other registers are
preserved.
All elementary types up to 4 bytes are returned in register d0 like
common on the Amiga (although I think pointers should better be returned
in a0). If compiled for an fpu, floating point values are returned in
fp0 unless -no-fpreturn is specified.
Types which are 8, 12 or 16 bytes large will be returned in several
registers (d0/d1/a0/a1) unless -no-mreg-return is specified.
All other types are returned by passing the function the address
of the result as a hidden argument - so when you call such a function
without a proper declaration in scope you can expect a crash.
You must not link objects together that have been compiled with
different settings!
vbcc uses d0-d7 and a0-a6 for temporary results and register variables
(a4 is used as small data pointer if -sd is used). a5 can be
used as frame pointer for automatic variables (but this is not necessary -
they can be accessed through a7, too). At the moment all local
variables are addressed via (dist,ax), so a function may have only ~32k
of local variables if code for <=68000 is generated.
The elementary data types are represented like:
type size in bits alignment in bytes
char 8 1
short 16 2
int 32 2
long 32 2
all pointers 32 2
float(fpu) 32 2 see below
double(fpu) 64 2 see below
Although it would be better to have all 32bit+ types aligned to 4 bytes
I chose 2 bytes to be compatible with the Amiga system structures which
unfortunately have longwords aligned to 4n+2-addresses.
The amiga68k code generator at the moment only works on systems
that store floats and doubles in a similar way (IEEE) like the Amiga.
SMALL DATA
vbcc can access static data in two ways. By default all such data will
be accessed with full 32bit addresses (large data model).
However there is a second way. You can set up an address register (a4)
to point into your data segment and then address data with a 16bit
offset through this register.
The advantages of the small data model are that your program will
usually be smaller (because the 16bit offsets use less space and no
relocation information is needed) and faster.
The disadvantages are that one address register cannot be used by the
compiler and that you can use it only if all your static data occupies
less than 64kb. Also you may not mix object modules and libraries that
have been compiled with different data models (